package com.pinyoumei.app.utils;

/**
 * Created by Administrator on 2020-08-25.
 * --------- 日期 ------- 维护人 ------------ 变更内容 --------
 * 2020-08-25        Administrator             新增Person类
 * 2020-08-25        Administrator             增加sex属性
 */


import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.widget.Toast;

import com.pinyoumei.app.activity.LuckPanActivity;
import com.pinyoumei.app.activity.MyBillActivity;
import com.pinyoumei.app.activity.wallet.RechargeActivity;
import com.pinyoumei.app.activity.ShoppingCenter.jd.JDMainActivity;
import com.pinyoumei.app.activity.ShoppingCenter.pdd.PddMainActivity;
import com.pinyoumei.app.activity.ShoppingCenter.taobao.ShopTaoMainActivity;
import com.pinyoumei.app.activity.ShoppingCenter.wm.WmActivity;
import com.pinyoumei.app.activity.ShoppingCenter.wph.WphMainActivity;
import com.pinyoumei.app.activity.SignInActivity;
import com.pinyoumei.app.activity.UserManageActivity;
import com.pinyoumei.app.activity.giftbag.GiftBagActivity;
import com.tencent.mm.opensdk.modelmsg.SendAuth;
import com.tencent.mm.opensdk.openapi.IWXAPI;
import com.tencent.mm.opensdk.openapi.WXAPIFactory;

/**
 * 主要功能:手机管理工具类
 */

public class IntentUtils {


    /**
     * @param model_method
     * @return
     */
    public static void Intent_to(Context context, String model_method, String name) {
        switch (model_method) {
            case "jd_union":
                //京东返利
                context.startActivity(new Intent(context, JDMainActivity.class));
                break;

            case "tb_union":
                //淘宝返利
                context.startActivity(new Intent(context, ShopTaoMainActivity.class));
                break;

            case "vph_union":
                //唯品会返利
                context.startActivity(new Intent(context, WphMainActivity.class));
                break;
            case "pdd_union":
                //拼多多返利
                context.startActivity(new Intent(context, PddMainActivity.class));
                break;
            case "waimai_union":
                //外卖返利
                context.startActivity(new Intent(context, WmActivity.class));
                break;

                case "lucky_pride":
                    //幸运转盘
                    context.startActivity(new Intent(context, LuckPanActivity.class));
                break;
                case "custom_manage":
//                    客户管理
                    context.startActivity(new Intent(context, UserManageActivity.class));
                break;

                case "my_bill":
//                    我的账单
                    context.startActivity(new Intent(context, MyBillActivity.class));
                break;

                case "charge_withdraw":
//                    充值提现
                    context.startActivity(new Intent(context, RechargeActivity.class));
                break;

            case "market_tb_block":
                //淘宝专区
                context.startActivity(new Intent(context, ShopTaoMainActivity.class));

                break;
            case "market_jd_block":
                //京东专区
                context.startActivity(new Intent(context, JDMainActivity.class));

                break;
            case "market_vph_block":
                //唯品会专区
                context.startActivity(new Intent(context, WphMainActivity.class));
                break;
            case "market_pdd_block":
                //拼多多专区
                context.startActivity(new Intent(context, PddMainActivity.class));
                break;
            case "market_wm_block":
                //外卖返现
                context.startActivity(new Intent(context, WmActivity.class));

                break;
            case "giftbag_union":
                //礼包转区
                context.startActivity(new Intent(context, GiftBagActivity.class));

                break;
            case "sign_union":
                //签到
                context.startActivity(new Intent(context, SignInActivity.class));
                break;
            default:
                break;
        }
    }

    /**
     * 登录微信
     *
     * @param
     */
    public static void loginWeixin(Context context, String weixin_app_id) {

        if (TextUtils.isEmpty(weixin_app_id)) {
            Toast.makeText(context.getApplicationContext(), "app_id 不能为空", Toast.LENGTH_SHORT).show();
        }
        IWXAPI api = WXAPIFactory.createWXAPI(context, weixin_app_id, true);
        api.registerApp(weixin_app_id);

        // 判断是否安装了微信客户端
        if (!api.isWXAppInstalled()) {
            Toast.makeText(context.getApplicationContext(), "您还未安装微信客户端！", Toast.LENGTH_SHORT).show();
            return;
        }
        // 发送授权登录信息，来获取code
        SendAuth.Req req = new SendAuth.Req();
        // 应用的作用域，获取个人信息
        req.scope = "snsapi_userinfo";
        /**
         * 用于保持请求和回调的状态，授权请求后原样带回给第三方
         * 为了防止csrf攻击（跨站请求伪造攻击），后期改为随机数加session来校验
         */
        req.state = "app_wechat";
        api.sendReq(req);
    }
}




